<template>
  <div class="movieList">
    <div class="listHeader">
      <div class="h-left">
        <slot name="icon"></slot>
        <slot name="title"></slot>
      </div>
      <div class="h-right">
        <slot name="more"></slot>
      </div>
    </div>
    <div class="listContent">
      <div class="item" v-for="item of movies" :key="item._id">
        <img :src="item.pic" alt="" @click="goDetail(item._id)" />
        <p>{{ item.title }}</p>
        <div>
            <span>{{item.rating}}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
    props:{
        movies:{
            type:Array
        }
    },
    methods: {
      goDetail(id){
          this.$router.push(`/movie/detail/${id}`)
      }  
    },
};
</script>

<style scoped>
.movieList{
    padding: 0.3rem;
}
.listHeader {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-top: 1px solid #f5f5f5;
}
.listContent {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}
.listContent .item {
  width: 2.8rem;
}
.listContent .item img {
  width: 100%;
  height: 4rem;
  margin-bottom: 0.2rem;
}
.h-left{
    display: flex;
    align-items: center;
}
.h-left img{
    margin-right: 0.2rem;
}
</style>